﻿using System;
using EnvDTE;
using EnvDTE80;
using System.Text;
using Microsoft.VisualStudio.CommandBars;
using System.IO;
using System.Diagnostics;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using VSAddins;
using System.Threading;
using ProcrastinationKit.Connectivity;
using ProcrastinationKit.Connectivity.Configuration;
using System.Reflection;

namespace ProcrastinationKit
{
    public class PKAddin : VSInterface
    {
        private ProcrastinationKit _procrastinationKit;
        

        /// <summary>
        /// Initialize is the main routine that needs to be overriden to define the specific interface that
        /// HyperAddin provides.  
        /// </summary>
        public override void Initialize(DTE2 dte, bool UIInit)
        {
            Log.WriteLine("Initializing");
            
            //if (!UIInit && _procrastinationKit == null)
            if (!UIInit && _procrastinationKit == null)
            {
                _procrastinationKit = new ProcrastinationKit(dte, this);
                try
                {
                 //   _procrastinationKit.RegisterHyperLinkPrefix("msg");
                        
                }
                catch (Exception e)
                {
                    Log.WriteLineAlways("Error: Failure while registering 'msg:' prefix (hyperlinks won't work).");
                    Log.WriteLineAlways("   Exception: " + e.Message);
                    if (e is System.Security.SecurityException)
                        Log.WriteLineAlways("On VISTA, you must run Visual Studio at least once with elevated privileges.");
                }
                //Initializing PK4CS
                _procrastinationKit.Initialize();
            }
            AddinName = "PKAddin";

        }

        

        public override void Dispose()
        {
           
        }

        

    }
}
